//
//  ICMMemberView.m
//  ICrEAM
//
//  Created by kuroro on 16/11/22.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ICMMemberView.h"
#import "AppDelegate.h"

@interface ICMMemberView ()
@property (nonatomic, strong) TPKeyboardAvoidingScrollView *bigScrollView;
@end


@implementation ICMMemberView

#define TitleTFViewHeight           ActualHeight(65)


- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self){
        
        self.bigScrollView = [[TPKeyboardAvoidingScrollView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        self.bigScrollView.backgroundColor = [UIColor clearColor];
        self.backgroundColor = BackgroundColor_White;
        
        //第一行
        ICMTitleTextFeildView *memberCard = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewWithFrame:CGRectMake(ActualWidth(50), ActualHeight(20), ActualWidth(220), TitleTFViewHeight) title:@"会员卡号"];
        [self.bigScrollView addSubview:memberCard];
        
        ICMTitleTextFeildView *memberName = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewWithFrame:CGRectMake(ActualWidth(330),memberCard.y, ActualWidth(220), TitleTFViewHeight) title:[ICrEAMTool isVW]?@"会员名称":@"持卡人姓名"];
        [self.bigScrollView addSubview:memberName];
        
        self.memberCard = memberCard;
        self.memberName = memberName;
        
        //第二行
        
        ICMTitleTextFeildView *memberStatus = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewWithFrame:CGRectMake(memberCard.x, memberCard.bottomEdge+ActualHeight(25), ActualWidth(220), TitleTFViewHeight) title:[ICrEAMTool isVW]?@"会员卡状态":@"经销商代码"];
        [self.bigScrollView addSubview:memberStatus];
        
        ICMTitleTextFeildView *memberType = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewWithFrame:CGRectMake(memberName.x, memberStatus.y, ActualWidth(220), TitleTFViewHeight) title:[ICrEAMTool isVW]?@"会员卡类型":@"经销商名称"];
        [self.bigScrollView addSubview:memberType];
        
        self.memberStatus = memberStatus;
        self.memberType = memberType;

        //第三行
        ICMTitleTextFeildView *totalPoint = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewWithFrame:CGRectMake(memberStatus.x, memberStatus.bottomEdge+ActualHeight(50), ActualWidth(220), TitleTFViewHeight) title:[ICrEAMTool isVW]?@"会员积分":@"总部积分金额"];
        [self.bigScrollView addSubview:totalPoint];
        
        ICMTitleTextFeildView *availablePoint = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewWithFrame:CGRectMake(memberType.x, totalPoint.y, ActualWidth(220), TitleTFViewHeight) title:[ICrEAMTool isVW]?@"可用积分":@"验证码开关"];
        [self.bigScrollView addSubview:availablePoint];
        
        self.totalPoint = totalPoint;
        self.availablePoint = availablePoint;
        
        //第四行
        ICMTitleTextFeildView *frozenPoint = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewWithFrame:CGRectMake(totalPoint.x, totalPoint.bottomEdge+ActualHeight(25), ActualWidth(220), TitleTFViewHeight) title:[ICrEAMTool isVW]?@"冻结积分":@"经销商积分金额"];
        [self.bigScrollView addSubview:frozenPoint];
        
        self.frozenPoint = frozenPoint;
        

        if (![ICrEAMTool isVW]) {

            ICMTitleTextFeildView *isBinding = [ICMTitleTextFeildView createNoneditableICMTitleTextFeildViewWithFrame:CGRectMake(availablePoint.x, totalPoint.bottomEdge+ActualHeight(25), ActualWidth(220), TitleTFViewHeight) title:@"是否绑定"];
            [self.bigScrollView addSubview:isBinding];
            
            self.isBinding = isBinding;
        }
       
        
        self.bigScrollView.contentSize = CGSizeMake(frame.size.width, frozenPoint.bottomEdge);
        [self addSubview:self.bigScrollView];

    }
    return self;
}


+ (instancetype)createICMMemberViewWithFrame:(CGRect)frame{
    return [[ICMMemberView alloc] initWithFrame:frame];
}
@end
